
Runner.pages.RightsPage=Runner.extend(Runner.pages.ListPage,{pageType:Runner.pages.constants.PAGE_ADMIN_RIGHTS,constructor:function(cfg){Runner.pages.RightsPage.superclass.constructor.call(this,cfg);},init:function(){this.initOldCode();this.fireEvent('afterInit',this,this.id);},initOldCode:function(){window.TEXT_AA_ADD_NEW_GROUP=##message AA_ADD_NEW_GROUP##;window.TEXT_AA_RENAMEGROUP=##message AA_RENAMEGROUP##;window.renameidx=-1;window.tables=Runner.pages.PageSettings.getTableData(this.tName,"rightsTables",false);window.groups=Runner.pages.PageSettings.getTableData(this.tName,"rightsGroups",false);window.fillboxes=function(group)
{var add_uncheck=false;var edt_uncheck=false;var del_uncheck=false;var lst_uncheck=false;var exp_uncheck=false;var imp_uncheck=false;var adm_uncheck=false;for(var g=0;g<groups.length;g++)
{for(var t=0;t<tables.length;t++)
{var disp='none';if(groups[g]==group)
{var tbl_uncheck=false;disp='';if((!tbl_uncheck||!add_uncheck)&&!document.getElementById('cbadd_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;add_uncheck=true;}
if((!tbl_uncheck||!edt_uncheck)&&!document.getElementById('cbedt_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;edt_uncheck=true;}
if((!tbl_uncheck||!del_uncheck)&&!document.getElementById('cbdel_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;del_uncheck=true;}
if((!tbl_uncheck||!lst_uncheck)&&!document.getElementById('cblst_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;lst_uncheck=true;}
if((!tbl_uncheck||!exp_uncheck)&&!document.getElementById('cbexp_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;exp_uncheck=true;}
if((!tbl_uncheck||!imp_uncheck)&&!document.getElementById('cbimp_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;imp_uncheck=true;}
if((!tbl_uncheck||!adm_uncheck)&&!document.getElementById('cbadm_'+tables[t]+'_'+groups[g]).checked)
{tbl_uncheck=true;adm_uncheck=true;}
document.getElementById(tables[t]).checked=!tbl_uncheck;}
document.getElementById('cbadd_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbedt_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbdel_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cblst_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbexp_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbimp_'+tables[t]+'_'+groups[g]).style.display=disp;document.getElementById('cbadm_'+tables[t]+'_'+groups[g]).style.display=disp;}}
document.getElementById('add').checked=!add_uncheck;document.getElementById('edt').checked=!edt_uncheck;document.getElementById('del').checked=!del_uncheck;document.getElementById('lst').checked=!lst_uncheck;document.getElementById('exp').checked=!exp_uncheck;document.getElementById('imp').checked=!imp_uncheck;document.getElementById('adm').checked=!adm_uncheck;if(group<0)
{document.getElementById('delgroup').disabled=true;document.getElementById('delgroup').className='button_dis button';document.getElementById('rengroup').disabled=true;document.getElementById('rengroup').className='button_dis button';}
else
{document.getElementById('delgroup').disabled=false;document.getElementById('delgroup').className='button';document.getElementById('rengroup').disabled=false;document.getElementById('rengroup').className='button';var gr=document.getElementById('group');renameidx=gr.selectedIndex;$('#groupname').val(gr.options[gr.selectedIndex].text);}}
var gsel=document.getElementById('group');if(gsel.selectedIndex<0)
gsel.selectedIndex=0;fillboxes(gsel.options[gsel.selectedIndex].value);window.deletegroup=function()
{var gr=document.getElementById('group');var disp=gr.options[gr.selectedIndex].text;var idx=gr.selectedIndex;var id=gr.options[idx].value;if(!confirm(##message AA_DELETEGROUP##+disp+'?'))
return;$.get('ug_group.##@ext##',{rndval:Math.random(),id:id,a:'del'},function(ret){if(ret!='ok')
{alert('Error deleting record!');return;}
for(var i=0;i<groups.length;i++)
if(groups[i]==id)
groups.splice(i,1);gr.selectedIndex--;gr.onchange();$('input[@type=checkbox][@id$=_'+id+']').each(function(){this.parentNode.removeChild(this);});gr.remove(idx);gr.size=gr.size-1;});}
window.makename=function(group)
{var n=1;var i;tgroup=group;var gr=document.getElementById('group');while(1)
{for(i=0;i<gr.options.length;i++)
{if(tgroup==gr.options[i].text)
break;}
if(i==groups.length)
{return tgroup;}
tgroup=group+n;n++;}}
window.save=function(name)
{if(renameidx==-1)
{$.get('ug_group.##@ext##',{rndval:Math.random(),name:name,a:'add'},function(ret)
{if(ret.substring(0,2)!='ok')
{alert('Error adding group!');return;}
var id=ret.substring(2);var gr=document.getElementById('group');$('#addarea').hide();$('input[@type=checkbox][@id$=_-1]').each(function()
{var cbid=$(this)[0].id;$(this.parentNode).append('<input type=checkbox  id="'+cbid.substring(0,cbid.length-2)+id+'" name="'+cbid.substring(0,cbid.length-2)+id+'">');});groups[groups.length]=id;gr.options[gr.options.length]=new Option(name,id);gr.selectedIndex=gr.options.length-1;gr.onchange();gr.size=gr.size+1;$('#groupname').val('');});}
else
{var idx=renameidx;renameidx=-1;var gr=document.getElementById('group');$.get('ug_group.##@ext##',{rndval:Math.random(),id:gr.options[idx].value,name:name,a:'rename'},function(ret){if(ret.substring(0,2)!='ok')
{alert('Error renaming group!');return;}
$('#addarea').hide();gr.options[idx].text=name;$('#groupname').val('');});}};}});